package com.woniu.cq.medical.dao;

import com.woniu.cq.medical.controller.form.AttendanceRecordForm;
import com.woniu.cq.medical.entity.AttendanceRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Lucas
 * @since 2020-09-07
 */
public interface AttendanceRecordMapper extends BaseMapper<AttendanceRecord> {

    void changeAttendanceRecord(@Param("doctorId") int doctorId,@Param("date") Date date, @Param("currPatient") String currPatient);

    void changeAttendanceRecordCheckedCount(@Param("doctorId")int doctorId,@Param("date") Date date,@Param("currPatient") String currPatient);

    void changeAttendanceRecordWaitCheckCount(int doctorId, Date date);

    long totalCount(@Param("administrativeName") String administrativeName,@Param("doctorName") String doctorName,@Param("doctorDuty") String doctorDuty,@Param("attendanceDateBefore") Date attendanceDateBefore, @Param("attendanceDateAfter") Date attendanceDateAfter);

    List<AttendanceRecordForm> pageQuery(@Param("pageStart") int pageStart, @Param("pageSize")int pageSize, @Param("administrativeName")String administrativeName,
                                         @Param("doctorName")String doctorName, @Param("doctorDuty")String doctorDuty, @Param("attendanceDateBefore")Date attendanceDateBefore, @Param("attendanceDateAfter")Date attendanceDateAfter);

    @Select("select * from lonbon_attendance_record where doctor_id=#{doctorId} and attendance_date=#{attendanceDate} ")
    AttendanceRecord selectDoctorWaitCheckCount(Integer doctorId,Date attendanceDate);

    @Update("update lonbon_attendance_record set wait_check_count=#{waitCheckCount} where attendance_record_id=#{attendanceRecordId}")
    int updateWaitCheckCount(Integer waitCheckCount,Integer attendanceRecordId);

    int selectAttendanceRecord(@Param("doctorId") int doctorId, @Param("date") Date date);
}
